﻿using B.S.Sterilizationcenter.Domain.zmc;
using B.S.Sterilizationcenter.Domain.zyy;
using B.S.Sterilizationcenter.ErrorCode;
using B.S.Sterilizationcenter.Read.API.Application.Command.ReturnApplications;
using MediatR;
using SqlSugar;

namespace B.S.Sterilizationcenter.Read.API.Application.Handler.ReturnApplications
{
    public class GetReturnAppHandler : IRequestHandler<GetReturnAppCommand, ApiResult<List<ReturnApplication>>>
    {
        private readonly ISqlSugarClient db;

        public GetReturnAppHandler(ISqlSugarClient db)
        {
            this.db = db;
        }

        public async Task<ApiResult<List<ReturnApplication>>> Handle(GetReturnAppCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<ReturnApplication>> result = new ApiResult<List<ReturnApplication>>();
            result.Code = ApiEnums.查询成功;
            result.Msg = "查询成功";
            var list = db.Queryable<ReturnApplication>().Where(x => x.IsDelete == false).ToList();
            result.Data = list;
            return result;
        }
    }
}
